﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using ABMath.Miscellaneous;
using ABMath.ModelFramework.Data;
using MathNet.Numerics.Distributions;
using MathNet.Numerics.LinearAlgebra;
using NUnit.Framework;

namespace ABMath.Tests.Miscellaneous
{
    [TestFixture]
    public class BStatisticTest
    {
        private BStatistic bStat;

        [SetUp]
        public void Setup()
        {
            bStat = new BStatistic(12);
        }

        [Test]
        public void BasicTest()
        {
            var sd = new StandardDistribution();
            const int numIts = 1000;

            var summary = new Vector(numIts);
            for (int iter = 0; iter < numIts; ++iter)
            {
                var ts = new TimeSeries();
                var cur = new DateTime(2001, 1, 1);
                for (int i = 0; i < 200; ++i)
                {
                    ts.Add(cur, sd.NextDouble(), true);
                    cur = new DateTime(cur.AddDays(1).Ticks);
                }

                Vector acf = ts.ComputeACF(50, true);
                bStat.ComputeFrom(acf, ts.Count);
                summary[iter] = bStat.pValues[0];
            }
        }
    }
}
